package com.sv.zgydor.controller;

import com.sv.zgydor.pojo.pg.TProjectListEntity;
import com.sv.zgydor.pojo.pg.Table1Entity;
import com.sv.zgydor.service.Table1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Class summary
 * User: kevin
 * Date: 2017/09/13
 * Time: 21:04
 * Description:
 */
@Controller
public class HomeController {

    @Autowired
    private Table1Service table1Service;

    /**
     * 跳转到首页
     *
     * @return 首页
     */
    @RequestMapping(value = "/index")
    public String home() {
        return "project/projectList";
    }

    /**
     * 登录
     *
     * @return 登录页
     */
    @RequestMapping(value = "/login")
    public String login() {
        return "login";
    }

    /**
     * Grid测试页
     *
     * @return Grid测试页
     */
    @RequestMapping(value = "/grid")
    public String grid() {
        return "gridTest/grid";
    }

    /**
     * Grid1测试页
     *
     * @return Grid1测试页
     */
    @RequestMapping(value = "/grid1")
    public String grid1() {
        return "gridTest/grid1";
    }

    /**
     * JSON提交测试页面
     * @param projectListEntity 对象
     * @return JSON返回
     */
    @RequestMapping(value = "/jsonTest", method = RequestMethod.POST)
    public @ResponseBody
    TProjectListEntity jsonTest(@RequestBody TProjectListEntity projectListEntity) {
        TProjectListEntity tmp = projectListEntity;
        return tmp;
    }

    @RequestMapping(value="/test")
    public void testInsert(){
        Table1Entity t1 = new Table1Entity();
        t1.setId1(new Long(10));
        t1.setName1("kangkai");
        this.table1Service.save(t1);
    }
}
